package com.example.inteviewwhy.service.impl;

import com.example.inteviewwhy.dao.UserRepository;
import com.example.inteviewwhy.entity.User;
import com.example.inteviewwhy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserRepository userRepository;

    @Override
    public <S extends User> S save(S entity) {

        return userRepository.save(entity);
    }

    @Override
    public List<User> findAll(String name) {
        return userRepository.findAll(name);
    }

    @Override
    public User findDetail(Long uid) {
        return userRepository.findDetail(uid);
    }


    @Override
    public boolean delete(User user) {
        try {
            userRepository.delete(user);
        }catch (Exception exception){
            return false;
        }
        return true;
    }
}
